package com.jstyle.jclife.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.jstyle.jclife.R;
import com.jstyle.jclife.utils.ScreenUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/9/27.
 */

public class TipsDialog extends JstyleDialog {


    @BindView(R.id.bt_title)
    Button btTitle;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.button_cancel)
    Button buttonCancel;
    @BindView(R.id.button_confim)
    Button buttonConfim;
    @BindView(R.id.view_divider)
    View viewDivider;

    public TipsDialog(@NonNull Context context) {
        super(context);

    }

    public TipsDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        init(context, themeResId);
    }

    private void init(Context context, int themeResId) {
        initStyle(themeResId);
        initWidth(ScreenUtils.getScreenWidth(context));
        initGravity(Gravity.CENTER);
    }


    @Override
    protected void setContentView() {
        setContentView(R.layout.dialog_tips);
    }


    @OnClick({R.id.button_cancel, R.id.button_confim})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.button_cancel:
                if(cancelListener!=null)cancelListener.onCancel();
                dismiss();
                break;
            case R.id.button_confim:
                if(tipsConfimListener!=null)tipsConfimListener.onConfim();
                dismiss();
                break;
        }
    }
    public TipsDialog setTipsConfimListener(TipsConfimListener confimListener){
        this.tipsConfimListener=confimListener;
        return this;
    }
    public TipsDialog setTipsCancelListener(TipsCancelListener cancelListener){
        this.cancelListener=cancelListener;
        return this;
    }
    public void setTitle(String text){
        btTitle.setText(text);
    }
    public void setContent(String text){
        tvContent.setText(text);
    }
    public void setButtonCancelGone(){
        buttonCancel.setVisibility(View.GONE);
    }
    public void setConfimText(String text){
        buttonConfim.setText(text);
    }
    TipsConfimListener tipsConfimListener;
    public interface TipsConfimListener{
        public void onConfim();
    }
    TipsCancelListener cancelListener;
    public interface TipsCancelListener{
        public void onCancel();
    }
}
